<include file="public@head"/>
<link rel="stylesheet" href="/static/xiaogu/fileupload/css/jquery.fileupload.css">

<div class="jubao-page">
    <div class="wrap-box">
        <div class="jubao-container">
            <div class="jubao-nav">
                <ul class="list-style">
                    <li class="step1">
                        <a href="{:cmf_url('portal/jubao/index')}">

                        <img src="/static/xiaogu/images/jubao_step1.png" alt="">
                        </a>
                    </li>
                    <li class="step2">
                        <a href="{:cmf_url('portal/list/index',array('id'=>13))}">

                        <img src="/static/xiaogu/images/jubao_step2.png" alt="">
                        </a>
                    </li>
                    <li class="step3">
                        <a href="{:cmf_url('portal/jubao/query')}">
                        <img src="/static/xiaogu/images/jubao_step3.png" alt="">
                        </a>
                    </li>
                </ul>
                <div class="c"></div>
            </div>

            <div class="line"></div>


            <div class="jubao-items" id="step1">
                <div class="jubao-item1">
                    <div class="warning f">
                        <img src="/static/xiaogu/images/jubao_warn.png" alt="">
                    </div>

                    <div class="jubao-tips f">
                        <p class="title">网上举报须知</p>
                        <div class="content">
                            <div class="f">一：</div>
                            <div class="f">
                                <p>纪检监察机关举报网站受理范围</p>
                                <p><strong>1.</strong>受理对党组织、党员和监察对象违反党纪行为的检举报告；</p>
                                <p><strong>2.</strong>依法应由纪检监察机关受理的党组织、党员和监察对象不服党纪政纪处分和其他处理的申诉；</p>
                                <p><strong>3.</strong>对党风廉政建设和反腐败工作的意见和建议；</p>
                            </div>
                            <div class="c"></div>
                        </div>

                        <div class="content">
                            <div class="f">二：</div>
                            <div class="f">
                                <p>举报人对举报事实的真实性负责。对于借举报捏造事实，诬告陷害的，依照有关规定严肃处</p>
                                    <p>理；涉嫌犯罪的，移交司法机关处理；</p>
                            </div>
                            <div class="c"></div>
                        </div>

                        <div class="content">
                            <div class="f">三：</div>
                            <div class="f">
                                <p>根据 "分级负责，归口办理" 原则，请您按照被举报人属地和级别，选择相应的举报网站进行举报；</p>
                            </div>
                            <div class="c"></div>
                        </div>

                        <div class="content">
                            <div class="f">四：</div>
                            <div class="f">
                                <p>纪检机关提倡实名举报 （ 请填写真实姓名，身份证号，家庭住址或工作单位及准确联系方式等内容。）；</p>
                            </div>
                            <div class="c"></div>
                        </div>

                        <div class="content">
                            <div class="f">五：</div>
                            <div class="f">
                                <p style="color: red;font-weight: bold">您当前的IP地址为{$ip}，您本人提交的举报内容全部真实，并愿对此承担相应的法律责任</p>
                            </div>
                            <div class="c"></div>
                        </div>


                        <div class="content" style="text-align: center">
                            <input type="checkbox" id="readCheck"> 我已阅读以上条款
                        </div>

                        <div id="confirm" style="text-align: center">
                            <button class="jubao-btn">（<span id="conform-time">15</span>秒）</button>
                        </div>

                        <div id="jubao-submit" style="text-align: center;display: none">
                            <button class="jubao-btn">署名举报</button>
                            <button class="jubao-btn">匿名举报</button>
                        </div>
                    </div>

                    <div class="c"></div>
                </div>


            </div>

            <form action="__URL__/" name="jubao">
            <div id="step2" class="jubao-table" style="display: none">
                <ul class="list-style">

                    <li class="jubao-head odd">举报人信息</li>
                    <li class="jubao-head">被举报人信息</li>

                    <li class="jubao-userinfo jubao-userinfo1 odd">
                        <div class="user">
                            <span>姓名：</span><input type="text" name="username" id="username" class="small-input">
                            <span>联系电话：</span><input type="text" name="phone" id="phone" class="small-input">
                        </div>
                        <div class="idno">
                            <span>身份证号码：</span><input type="text" name="idno" id="idno" class="middle-input">
                        </div>
                    </li>

                    <li class="jubao-userinfo">
                        <div class="user">
                            <span>被举报人：</span><input type="text" id="reported_name" name="beijubaoren" class="small-input">
                            <span>职务：</span><input type="text" name="reported_job" id="reported_job" class="small-input">
                        </div>
                    </li>

                    <li class="jubao-head odd">举报正文</li>
                    <li class="jubao-head">附件上传</li>

                    <li class="jubao-detail odd">
                        <div class="title">
                            <span>举报标题：</span>
                            <input type="text" name="title" id="title" class="large-input">
                        </div>
                        <div class="content">
                            <div class="tips">
                                主要问题（剩余 <span id="word-count">3000</span>字）：
                            </div>
                            <textarea name="content" id="content" class="jubao-content"></textarea>
                        </div>
                    </li>

                    <li class="jubao-attach">
                        <div class="title">
                            <span>附件</span>
                            <span class="btn btn-success fileinput-button">
                                <button class="jubao-btn">选择文件</button>
                                <input id="fileupload" type="file" name="file" multiple>
                            </span>




                        </div>
                        <div class="attach-list">


                        </div>
                    </li>

                </ul>
                <div class="c"></div>
                <div class="jubao-submit">
                    <span>验证码</span>
                    <input type="text" name="verify_code" id="verify_code" class="small-input">
                    <span><img src="{:captcha_src()}" id="captcha" width="120" height="40" onclick="this.src=this.src+'?'+Math.random()" alt="captcha" /></span>
                    <button class="jubao-btn" type="button" id="submit">提交</button>
                </div>
            </div>
                <input type="hidden" id="report_type" name="report_type" value="0">
            </form>
            <div class="c"></div>

        </div>
    </div>
</div>
<include file="public@footer"/>

<script src="/static/xiaogu/fileupload/js/vendor/jquery.ui.widget.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="/static/xiaogu/fileupload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="/static/xiaogu/fileupload/js/jquery.fileupload.js"></script>
<script>
    $(function() {
        var attachlist = [];
        $('#fileupload').fileupload({
            url: "/portal/index/upload",
            dataType: 'json',
            done: function (e, data) {
                var filename = data.files[0].name;
                var result = data.result;
                if(result.code != 1) {
                    alert(result.msg);
                    return;
                }
                var ext = result.data.ext;
                if(ext == 'doc' || ext=='docx') {
                    var html = '<div class="attach-item attach-doc"><span class="del"></span> ' +
                        '<span>'+filename+'</span> ' +
                        '</div>';
                }else {
                    var html = '<div class="attach-item"> <span class="del"></span>' +
                        '<img src="/' + result.data.path + '"> ' +
                        '</div>';
                }
                attachlist = attachlist.concat({filename : filename, path: result.data.path});

                $(".attach-list").append(html);
                console.log(data);
//                $.each(data.result.files, function (index, file) {
//                    $('<p/>').text(file.name).appendTo('#files');
//                });
            },
            progressall: function (e, data) {
                var progress = parseInt(data.loaded / data.total * 100, 10);
                $('#progress .progress-bar').css(
                    'width',
                    progress + '%'
                );
            }
        }).prop('disabled', !$.support.fileInput)
            .parent().addClass($.support.fileInput ? undefined : 'disabled');

        // 倒计时
        function clockCountDown() {
            var count = 15;
            var interval = setInterval(function () {
                count = count - 1;
                $("#conform-time").text(count);
                if (count == 0) {
                    clearInterval(interval);
                    showSubmitBtns();
                }
            }, 1000);
        }

        function showSubmitBtns() {
            $("#confirm").hide();
            $("#jubao-submit").show();
        }

        clockCountDown();

        $(".attach-list").on('click','.del',function() {
            var index = $(this).index();
            console.log(attachlist);

             attachlist.splice(index,1);
             $(this).parent().remove();
             console.log(attachlist);
        });

        $("#jubao-submit .jubao-btn").click(function() {
            // 判断
            if($("#readCheck").is(":checked") == false ){
                alert('请勾选同意条款');
                return ;
            }
            var index = $(this).index();
            if(index == 1) {
                $("#report_type").val(0);
                $(".jubao-userinfo1").empty();
            }else {
                $("#report_type").val(1);
            }
            $("#step1").hide();
            $("#step2").show();
        });

        $("#content").keyup(function() {
            var wordCount = 0;
            var count =  $(this).val().length;
            if (count >= 3000) {
                wordCount = 0;
            } else {
                wordCount = 3000 - count;
            }
            $("#word-count").text(wordCount);
        });
        $("#submit").click(function() {
           submit();
        });

        function submit() {
            var data = {
                title: $("#title").val(),
                content: $("#content").val(),
                username: $("#username").val(),
                phone: $("#phone").val(),
                idno: $("#idno").val(),
                reported_name: $("#reported_name").val(),
                reported_job: $("#reported_job").val(),
                report_type: $("#report_type").val(),
                attach_list: $("#attach_list").val(),
                verify_code: $("#verify_code").val(),
                attachlist : JSON.stringify(attachlist)
            };
            console.log(data);
            if(!data.title) {
                alert("请输入举报标题");
                return;
            }
            if(!data.content) {
                alert("请输入举报内容");
                return ;
            }
            if(!data.reported_name) {
                alert("请输入被举报人姓名");
                return false;
            }
            if(!data.reported_job) {
                alert("请输入举报人职务");
                return ;
            }
            if(data.report_type == 1) {
                if(!data.username) {
                    alert("请输入举报人姓名");
                    return false;
                }
                if(!data.phone) {
                    alert("请输入手机号");
                    return;
                }
                if(!data.idno) {
                    alert("请输入身份证号码");
                    return;
                }
            }
            var url = "{:cmf_url('portal/jubao/dosubmit')}";
            $.post(url, data, function(res) {
               if(res.code == 1) {
                   // 成功
                   var code = res.data.code;
                   window.location.href = "{:cmf_url('portal/jubao/jubao_success')}" + "?code=" + code;
               }  else {
                   alert(res.msg);
               }
            });
        }
    })
</script>

</body>

</html>